package org.example.model;

public class Harvester extends FarmMachine {
    private double harvestWidth;
    private double grainCapacity;
    private double currentLoad;

    public Harvester(String id) {
        super(id);
        this.type = "收割机";
        this.harvestWidth = 4.5;
        this.grainCapacity = 5.0;
        this.currentLoad = 0.0;
    }

    @Override
    public void performTask() {
        if (currentLoad >= grainCapacity) {
            System.out.println(type + "[" + id + "] 粮食容量已满，需要卸载");
            return;
        }

        double harvested = Math.random() * 1.0;
        if (currentLoad + harvested > grainCapacity) {
            harvested = grainCapacity - currentLoad;
        }

        currentLoad += harvested;
        System.out.println(type + "[" + id + "] 正在执行收割任务: 宽度=" + harvestWidth + "m, 已装载=" + currentLoad + "吨");

        if (currentLoad >= grainCapacity) {
            System.out.println(type + "[" + id + "] 粮食容量已满，返回卸载点");
        }
    }

    public double getHarvestWidth() { return harvestWidth; }
    public void setHarvestWidth(double harvestWidth) { this.harvestWidth = harvestWidth; }
    public double getGrainCapacity() { return grainCapacity; }
    public void setGrainCapacity(double grainCapacity) { this.grainCapacity = grainCapacity; }
    public double getCurrentLoad() { return currentLoad; }
    public void setCurrentLoad(double currentLoad) { this.currentLoad = currentLoad; }
}